//Iditarod Trail
//Amelia Bauer, Elise Eiden, Christine Gerardi, Taryn Green
//CSE 20212 2012
/*Yes/No exit window to be called in MainWindow upon exiting*/
#include "AreYouSureWindow.h"
#include <QtGui>
#include <QPushButton>
#include <QApplication>
#include <QGridLayout>
#include <QString>
#include <QLabel>
#include <iostream>
#include <QFont>
using namespace std;

//Constructor
AreYouSureWindow::AreYouSureWindow(QTimer* timer, QWidget *parent):QWidget(parent)
{
	clock = timer;
	//Sets up window
	setWindowTitle(QString("Exit?"));
	resize(120,120);
	
	/*//specify a new font.
	QFont newFont("Arial", 16, QFont::Bold, true);
	//set font of application
	QApplication::setFont(newFont);*/

	//Adds and displays widgets
	QGridLayout *layout = new QGridLayout(this);
	QLabel *text = new QLabel(QString("Are you sure you want to exit?"));
	QPushButton *yes = new QPushButton(QString("Yes"));
	QPushButton *no = new QPushButton(QString("No"));
	layout->addWidget(text,0,1);
	layout->addWidget(yes,1,0);
	layout->addWidget(no,1,2);
	setLayout(layout);

	//Connects buttons to slots
	connect(yes, SIGNAL(clicked()), this, SLOT(close()));
	connect(no, SIGNAL(clicked()), this, SLOT(closeThis()));

}

//Closes the pop up window
void AreYouSureWindow:: closeThis()
{
	clock->start(3000);
	this->hide();
}

//Closes the program 
void AreYouSureWindow:: close()
{
		exit(0);
}

